#include <iostream>
#include <memory>
using namespace std;
int main()
{
    std::shared_ptr<int> p1;
    p1.reset(new int(1));
    std::shared_ptr<int> p2 = p1;
    // 引用计数此时应该是2
    cout << "p2.use_count() = " << p2.use_count() << endl;
    p1.reset();
    cout << "p1.reset()\n";
   
    cout << "p2.use_count()= " << p2.use_count() << endl;
    if (!p1)
    {
        cout << "p1 is empty\n";
    }
    if (!p2)
    {
        cout << "p2 is empty\n";
    }
    p2.reset();
    cout << "p2.reset()\n";
    cout << "p2.use_count()= " << p2.use_count() << endl;
    if (!p2)
    {
        cout << "p2 is empty\n";
    }
    return 0;
}